<?php
	global $permisos;
	global $restaurants;
	$host='localhost';
	$link = mysql_connect('localhost', 'restorecipe', '3p6JY53rAAsTBJ5G') OR die(mysql_error());
	$result = mysql_query("USE restorecipe;");
	mysql_query("SET NAMES 'utf8'");
	if (isset($_SESSION['SESS_MEMBER_ID'])){
		$result = mysql_query("SELECT accion FROM permisos pm JOIN permisosXperfiles pp ON pp.idpermiso=pm.id JOIN members m ON m.idperfil=pp.idperfil WHERE member_id=".$_SESSION['SESS_MEMBER_ID']);
		$permisos=array();
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			$permisos[$row['accion']]=1;
		}
		
		$result = mysql_query("SELECT r.id, r.nombre FROM restaurant r JOIN membersXrestaurants mr ON mr.idrestaurant=r.id WHERE member_id=".$_SESSION['SESS_MEMBER_ID']);
		$restaurants=array();
		//echo "SELECT r.id, r.nombre FROM restaurant r JOIN membersXrestaurants mr ON mr.idrestaurant=r.id WHERE member_id=".$_SESSION['SESS_MEMBER_ID']; exit;
		if (!isset($_SESSION['Restaurant_ID']) )$_SESSION['Restaurant_ID']=0;
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			if (empty($_SESSION['Restaurant_ID'])){
				$_SESSION['Restaurant_ID'] = $row['id'];
			}
			$restaurants[$row['id']]=$row['nombre'];
		}
	}
	
	
	function clean($str) {
                $str = @trim($str);
                if(get_magic_quotes_gpc()) {
                        $str = stripslashes($str);
                }
                return mysql_real_escape_string($str);
	}

?>
